
$logFile = [String]::Format('{0}\{1}', $env:BTAD_InstallDir, 'Deployment\Sixeyed.CacheAdapter.Install.ps1.log')
[IO.File]::Delete($logFile)
[IO.File]::AppendAllText($logFile, [String]::Format('Installation started: {0}{1}', [DateTime]::Now, [Environment]::NewLine))

$runtimePath = [String]::Format('{0}\{1}', $env:BTAD_InstallDir, 'Sixeyed.CacheAdapter.Runtime.dll')
$managementPath = [String]::Format('{0}\{1}', $env:BTAD_InstallDir, 'Sixeyed.CacheAdapter.Management.dll')

[IO.File]::AppendAllText($logFile, 'Creating registry keys & values')
[IO.File]::AppendAllText($logFile, [Environment]::NewLine)

New-PSDrive -Name CLSID -PSProvider Registry -Root HKEY_CLASSES_ROOT\CLSID

New-Item -Path 'CLSID:\{416890a7-76e8-4d4d-932d-fca1c4dcce5d}' -force
New-ItemProperty -Path 'CLSID:\{416890a7-76e8-4d4d-932d-fca1c4dcce5d}' -Name '(Default)' -PropertyType String -Value 'Cache Adapter' -force
New-ItemProperty -Path 'CLSID:\{416890a7-76e8-4d4d-932d-fca1c4dcce5d}' -Name 'AppID' -PropertyType String -Value '{eda83931-54c6-42b1-ac12-ae157d83c552}' -force

New-Item -Path 'CLSID:\{416890a7-76e8-4d4d-932d-fca1c4dcce5d}\BizTalk' -force
New-ItemProperty -Path 'CLSID:\{416890a7-76e8-4d4d-932d-fca1c4dcce5d}\BizTalk' -Name '(Default)' -PropertyType String -Value 'BizTalk' -force
New-ItemProperty -Path 'CLSID:\{416890a7-76e8-4d4d-932d-fca1c4dcce5d}\BizTalk' -Name 'TransPortType' -PropertyType String -Value 'Cache' -force
New-ItemProperty -Path 'CLSID:\{416890a7-76e8-4d4d-932d-fca1c4dcce5d}\BizTalk' -Name 'Constraints' -PropertyType DWord -Value 9474 -force
New-ItemProperty -Path 'CLSID:\{416890a7-76e8-4d4d-932d-fca1c4dcce5d}\BizTalk' -Name 'TransmitLocation_PageProv' -PropertyType String -Value '{2DE93EE6-CB01-4007-93E9-C3D71689A282}' -force
New-ItemProperty -Path 'CLSID:\{416890a7-76e8-4d4d-932d-fca1c4dcce5d}\BizTalk' -Name 'OutboundEngineCLSID' -PropertyType String -Value '{dbe8615d-547a-4c76-8793-da0a1728200d}' -force
New-ItemProperty -Path 'CLSID:\{416890a7-76e8-4d4d-932d-fca1c4dcce5d}\BizTalk' -Name 'OutboundTypeName' -PropertyType String -Value 'Sixeyed.CacheAdapter.Runtime.CacheTransmitter' -force
New-ItemProperty -Path 'CLSID:\{416890a7-76e8-4d4d-932d-fca1c4dcce5d}\BizTalk' -Name 'OutboundAssemblyPath' -PropertyType String -Value $runtimePath -force
New-ItemProperty -Path 'CLSID:\{416890a7-76e8-4d4d-932d-fca1c4dcce5d}\BizTalk' -Name 'AdapterMgmtTypeName' -PropertyType String -Value 'Sixeyed.CacheAdapter.Management.AdapterManagement' -force
New-ItemProperty -Path 'CLSID:\{416890a7-76e8-4d4d-932d-fca1c4dcce5d}\BizTalk' -Name 'AdapterMgmtAssemblyPath' -PropertyType String -Value $managementPath -force
New-ItemProperty -Path 'CLSID:\{416890a7-76e8-4d4d-932d-fca1c4dcce5d}\BizTalk' -Name 'AliasesXML' -PropertyType String -Value '<AdapterAliasList><AdapterAlias>cache://</AdapterAlias></AdapterAliasList>' -force
New-ItemProperty -Path 'CLSID:\{416890a7-76e8-4d4d-932d-fca1c4dcce5d}\BizTalk' -Name 'PropertyNameSpace' -PropertyType String -Value 'http://schemas.sixeyed.com/CacheAdapter/2009' -force
New-ItemProperty -Path 'CLSID:\{416890a7-76e8-4d4d-932d-fca1c4dcce5d}\BizTalk' -Name 'SendLocationPropertiesXML' -PropertyType String -Value '<CustomProps><AdapterConfig vt=\"8\"/></CustomProps>' -force

New-Item -Path 'CLSID:\{416890a7-76e8-4d4d-932d-fca1c4dcce5d}\Implemented Categories' -force
New-Item -Path 'CLSID:\{416890a7-76e8-4d4d-932d-fca1c4dcce5d}\Implemented Categories\{7F46FC3E-3C2C-405B-A47F-8D17942BA8F9}' -force

[IO.File]::AppendAllText($logFile, [String]::Format('Installation completed: {0}', [DateTime]::Now))